﻿using Microsoft.WindowsAzure.StorageClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlobStroage
{
    public class PerformanceData : TableServiceEntity, IComparable
    {
        Int64 _eventTickCount;

        public Int64 EventTickCount
        {
            get
            {
                return _eventTickCount;
            }
            set
            {
                _eventTickCount = value;
            }
        }
        public string DeploymentId { get; set; }
        public string Role { get; set; }
        public string RoleInstance { get; set; }
        public string CounterName { get; set; }
        public double CounterValue { get; set; }

        public override bool Equals(object o)
        {
            if (this == o) return true;
            if (o == null || (o as PerformanceData) == null) return false;

            PerformanceData that = (PerformanceData)o;

            if (_eventTickCount != that._eventTickCount) return false;
            if (CounterName != null ? !CounterName.Equals(that.CounterName) : that.CounterName != null) return false;
            if (DeploymentId != null ? !DeploymentId.Equals(that.DeploymentId) : that.DeploymentId != null) return false;
            if (Role != null ? !Role.Equals(that.Role) : that.Role != null) return false;
            if (RoleInstance != null ? !RoleInstance.Equals(that.RoleInstance) : that.RoleInstance != null) return false;

            return true;
        }

        public override int GetHashCode()
        {
            int result = DeploymentId != null ? DeploymentId.GetHashCode() : 0;
            result = 31 * result + (Role != null ? Role.GetHashCode() : 0);
            result = 31 * result + (RoleInstance != null ? RoleInstance.GetHashCode() : 0);
            result = 31 * result + (CounterName != null ? CounterName.GetHashCode() : 0);
            result = 31 * result + (int)(_eventTickCount ^ (_eventTickCount >> 32));
            return result;
        }

        public int CompareTo(object obj)
        {
            return _eventTickCount.CompareTo(((PerformanceData)obj)._eventTickCount);
        }
    }
}
